package priv.dajie.tzzq.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import priv.dajie.tzzq.dao.SteamCsgoMapper;
import priv.dajie.tzzq.service.SteamCsgoService;
import priv.dajie.tzzq.spider.model.CsgoItemInfo;
import priv.dajie.tzzq.spider.model.CsgoItem;

/**
 * @ClassName SteamCsgoServiceImpl
 * @Description
 * @Author dajie
 * @Date 2019/11/9 1:34 下午
 * @Version V1.0
 **/

@Service
public class SteamCsgoServiceImpl implements SteamCsgoService {

    @Autowired
    SteamCsgoMapper steamCsgoMapper;

    @Override
    public boolean addInfo(CsgoItemInfo csgoItemInfo) {
        boolean success;
        success  = steamCsgoMapper.updateInfo(csgoItemInfo)>0;
        if (success){
            return true;
        }
        else {
            return steamCsgoMapper.addInfo(csgoItemInfo);
        }

//        return false;
    }

    @Override
    public boolean addItem(CsgoItem csgoItem) {
        boolean success = steamCsgoMapper.updateItem(csgoItem)>0;
        if (success){
            return true;
        }
        else{
            return steamCsgoMapper.addItem(csgoItem);
        }
//        return false;false
    }

    @Override
    public void addInfoAndItem(CsgoItem csgoItem) {
        addInfo(csgoItem.getCsgoItemInfo());
        addItem(csgoItem);
    }


}
